//
//  VRCollectionViewCell.m
//  MyDemos
//
//  Created by Veer on 16/8/9.
//  Copyright © 2016年 veer. All rights reserved.
//

#import "VRCollectionViewCell.h"


@interface VRCollectionViewCell()

@property (nonatomic, weak) UIImageView *backgroundImgView;

@end

@implementation VRCollectionViewCell


- (void)setImageName:(NSString *)imageName
{
    _imageName = imageName;
    self.backgroundImgView.image = [UIImage imageNamed:imageName];
}


- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        [self setupSubView];
    }
    return self;
}


- (void)setupSubView
{

    NSInteger rand0 = arc4random() % 255;
    NSInteger rand1 = arc4random() % 255;
    NSInteger rand2 = arc4random() % 255;
    self.backgroundColor = VRColor(rand0, rand1, rand2);
    
    UIImageView *backgroundImgView = [[UIImageView alloc] init];
    backgroundImgView.contentMode = UIViewContentModeScaleAspectFill;
    backgroundImgView.clipsToBounds = YES;
    [self.contentView addSubview:backgroundImgView];
    self.backgroundImgView = backgroundImgView;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [self.backgroundImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self.contentView);
    }];

}


@end
